﻿using MeiRiCai.Sdk.Core;
using MeiRiCai.Sdk.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MeiRiCai.Sdk
{
	public class LotteryDrawClient
	{
		private String baseServicePath = "/LotteryDraw";

		/// <summary>
		/// 获取最新开奖公告
		/// </summary>
		/// <param name="count">单页记录数</param>
		/// <param name="page">结果页码</param>
		/// <returns></returns>
		public List<LotteryDraw> GetLatestLotteryDraws(int count, int page)
		{
			String path = this.baseServicePath + "/Latest";
			Dictionary<String, Object> mapParams = new Dictionary<String, Object>();
			mapParams.Add("count", count);
			mapParams.Add("page", page);
			return SdkUtils.GetFromUrl<List<LotteryDraw>>(path, mapParams);
		}

		/// <summary>
		/// 获取某个彩种的最新开奖公告
		/// </summary>
		/// <param name="issuer">发行者</param>
		/// <param name="game">玩法（彩种）</param>
		/// <param name="count">单页记录数</param>
		/// <param name="page">结果页码</param>
		/// <returns></returns>
		public List<LotteryDraw> GetLotteryDraws(String issuer, String game, int count, int page)
		{
			String path = this.baseServicePath + "/List";
			Dictionary<String, Object> queryParams = new Dictionary<String, Object>();
			queryParams.Add("issuer", issuer);
			queryParams.Add("game", game);
			queryParams.Add("count", count);
			queryParams.Add("page", page);
			return SdkUtils.GetFromUrl<List<LotteryDraw>>(path, queryParams);
		}

		/// <summary>
		/// 获取某个彩种某一期的开奖公告
		/// </summary>
		/// <param name="issuer">发行者</param>
		/// <param name="game">玩法（彩种）</param>
		/// <param name="issue">期号</param>
		/// <returns></returns>
		public LotteryDraw GetLotteryDraw(String issuer, String game, String issue)
		{
			String path = this.baseServicePath + "/Detail";
			Dictionary<String, Object> queryParams = new Dictionary<String, Object>();
			queryParams.Add("issuer", issuer);
			queryParams.Add("game", game);
			queryParams.Add("issue", issue);
			return SdkUtils.GetFromUrl<LotteryDraw>(path, queryParams);
		}
	}
}
